home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / T / Think-Pascal-7.0.cpt / THINK Pascal Interfaces / Editions.p < prev    next >
Encoding:
Text File  |  1991-04-05  |  10.8 KB  |  322 lines  |  [TEXT/PJMM]

  1. {    This file has been processed by The THINK Pascal Source Converter, v1.1.    }
  2.  
  3. {}
  4. {Created: Tuesday, January 29, 1991 at 6:35 PM}
  5. {    Editions.p}
  6. {    Pascal Interface to the Macintosh Libraries}
  7. {}
  8. {        Copyright Apple Computer, Inc.    1989-1990}
  9. {        All rights reserved}
  10. {}
  11.  
  12.  
  13. {$IFC UNDEFINED UsingIncludes}
  14. {$SETC UsingIncludes := 0}
  15. {$ENDC}
  16.  
  17.  
  18. unit Editions;
  19. interface
  20.     uses
  21.         Types, Memory, OSUtils, Files, Dialogs, Appletalk, Aliases;
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.     const
  45.  
  46. { resource types  }
  47.         rSectionType = 'sect';                      { ResType of saved SectionRecords }
  48.  
  49. { section types }
  50.         stSubscriber = $01;
  51.         stPublisher = $0A;
  52.  
  53.         sumAutomatic = 0;                           { subscriber update mode - Automatically     }
  54.         sumManual = 1;                              { subscriber update mode - Manually }
  55.         pumOnSave = 0;                              { publisher update mode - OnSave            }
  56.         pumManual = 1;                              { publisher update mode - Manually }
  57.  
  58.         kPartsNotUsed = 0;
  59.         kPartNumberUnknown = -1;                    { misc }
  60.  
  61.         kPreviewWidth = 120;
  62.         kPreviewHeight = 120;
  63.  
  64.         kPublisherDocAliasFormat = 'alis';
  65.         kPreviewFormat = 'prvw';
  66.         kFormatListFormat = 'fmts';
  67.  
  68. { bits for formatsMask }
  69.         kPICTformatMask = 1;
  70.         kTEXTformatMask = 2;
  71.         ksndFormatMask = 4;
  72.  
  73. { Finder types for edition files }
  74.         kPICTEditionFileType = 'edtp';
  75.         kTEXTEditionFileType = 'edtt';
  76.         ksndEditionFileType = 'edts';
  77.         kUnknownEditionFileType = 'edtu';
  78.  
  79. { pseudo-item hits for dialogHooks }
  80. { the first if for NewPublisher or NewSubscriber Dialogs}
  81.         emHookRedrawPreview = 150;
  82.  
  83. { the following are for SectionOptions Dialog }
  84.         emHookCancelSection = 160;
  85.         emHookGoToPublisher = 161;
  86.         emHookGetEditionNow = 162;
  87.         emHookSendEditionNow = 162;
  88.         emHookManualUpdateMode = 163;
  89.         emHookAutoUpdateMode = 164;
  90.  
  91. { the refcon field of the dialog record during a modalfilter }
  92. { or dialoghook contains one the following}
  93.         emOptionsDialogRefCon = 'optn';
  94.         emCancelSectionDialogRefCon = 'cncl';
  95.         emGoToPubErrDialogRefCon = 'gerr';
  96.         kFormatLengthUnknown = -1;
  97.  
  98.     type
  99.         SectionType = SignedByte;                   { one byte, stSubscriber or stPublisher }
  100.         TimeStamp = LONGINT;                        { seconds since 1904 }
  101.         FormatType = packed array[1..4] of CHAR;   { similar to ResType as used by scrap mgr }
  102.         EditionRefNum = Handle;                     { used in Edition I/O }
  103. { update modes }
  104.         UpdateMode = INTEGER;                       { sumAutomatic, pumSuspend, etc }
  105.  
  106.         SectionPtr = ^SectionRecord;
  107.         SectionHandle = ^SectionPtr;
  108.         SectionRecord = record
  109.                 version: SignedByte;                    { always 0x01 in system 7.0 }
  110.                 kind: SectionType;                      { stSubscriber or stPublisher }
  111.                 mode: UpdateMode;                       { auto or manual }
  112.                 mdDate: TimeStamp;                      { last change in document }
  113.                 sectionID: LONGINT;                     { app. specific, unique per document }
  114.                 refCon: LONGINT;                        { application specific }
  115.                 alias: AliasHandle;                     { handle to Alias Record }
  116.                 subPart: LONGINT;                       { which part of container file }
  117.                 nextSection: SectionHandle;             { for linked list of app's Sections }
  118.                 controlBlock: Handle;                   { used internally }
  119.                 refNum: EditionRefNum;                  { used internally }
  120.             end;
  121.  
  122.         EditionContainerSpecPtr = ^EditionContainerSpec;
  123.         EditionContainerSpec = record
  124.                 theFile: FSSpec;
  125.                 theFileScript: ScriptCode;
  126.                 thePart: LONGINT;
  127.                 thePartName: Str31;
  128.                 thePartScript: ScriptCode;
  129.             end;
  130.  
  131.         EditionInfoRecord = record
  132.                 crDate: TimeStamp;                      { date EditionContainer was created }
  133.                 mdDate: TimeStamp;                      { date of last change }
  134.                 fdCreator: OSType;                      { file creator }
  135.                 fdType: OSType;                         { file type }
  136.                 container: EditionContainerSpec;        { the Edition }
  137.             end;
  138.  
  139.         NewPublisherReply = record
  140.                 canceled: BOOLEAN;                      { O }
  141.                 replacing: BOOLEAN;
  142.                 usePart: BOOLEAN;                       { I }
  143.                 preview: Handle;                        { I }
  144.                 previewFormat: FormatType;              { I }
  145.                 container: EditionContainerSpec;        { I/O }
  146.             end;
  147.  
  148.         NewSubscriberReply = record
  149.                 canceled: BOOLEAN;                      { O }
  150.                 formatsMask: SignedByte;
  151.                 container: EditionContainerSpec;        {I/O}
  152.             end;
  153.  
  154.         SectionOptionsReply = record
  155.                 canceled: BOOLEAN;                      { O }
  156.                 changed: BOOLEAN;                       { O }
  157.                 sectionH: SectionHandle;                { I }
  158.                 action: ResType;                        { O }
  159.             end;
  160.  
  161.  
  162.         ExpModalFilterProcPtr = ProcPtr;            { FUNCTION Filter(theDialog: DialogPtr; VAR theEvent: EventRecord; itemOffset: INTEGER; VAR itemHit: INTEGER; yourDataPtr: Ptr): BOOLEAN; }
  163.         ExpDlgHookProcPtr = ProcPtr;                { FUNCTION Hook(itemOffset, item: INTEGER; theDialog: DialogPtr; yourDataPtr: Ptr): INTEGER; }
  164.  
  165.         FormatIOVerb = (ioHasFormat, ioReadFormat, ioNewFormat, ioWriteFormat);
  166.  
  167.  
  168.         FormatIOParamBlock = record
  169.                 ioRefNum: LONGINT;
  170.                 format: FormatType;
  171.                 formatIndex: LONGINT;
  172.                 offset: LONGINT;
  173.                 buffPtr: Ptr;
  174.                 buffLen: LONGINT;
  175.             end;
  176.  
  177.  
  178.         FormatIOProcPtr = ProcPtr;                  { FUNCTION IO(selector: FormatIOVerb; VAR PB: FormatIOParamBlock): OSErr; }
  179.  
  180.         EditionOpenerVerb = (eoOpen, eoClose, eoOpenNew, eoCloseNew, eoCanSubscribe);
  181.  
  182.  
  183.         EditionOpenerParamBlock = record
  184.                 info: EditionInfoRecord;
  185.                 sectionH: SectionHandle;
  186.                 document: FSSpecPtr;
  187.                 fdCreator: OSType;
  188.                 ioRefNum: LONGINT;
  189.                 ioProc: FormatIOProcPtr;
  190.                 success: BOOLEAN;
  191.                 formatsMask: SignedByte;
  192.             end;
  193.  
  194.  
  195.         EditionOpenerProcPtr = ProcPtr;             { FUNCTION Opener(selector: EditionOpenerVerb; VAR PB: EditionOpenerParamBlock): OSErr; }
  196.  
  197.     const
  198.  
  199. { }
  200. {    Section events now arrive in the message buffer using the AppleEvent format.}
  201. {    The direct object parameter is an aeTemporaryIDParamType ('tid '). The temporary}
  202. {    ID's type is rSectionType ('sect') and the 32-bit value is a SectionHandle.}
  203. {    The following is a sample buffer}
  204. {    }
  205. {    name            offset    contents}
  206. {    ----            ------    --------}
  207. {    }
  208. {    header            0        'aevt'}
  209. {    majorVersion    4        0x01}
  210. {    minorVersion    6        0x01}
  211. {    endOfMetaData    8        ';;;;' }
  212. {    directObjKey    12        '----' }
  213. {    paramType        16        'tid ' }
  214. {    paramLength        20        0x0008 }
  215. {    tempIDType        24        'sect' }
  216. {    tempID             28        the SectionHandle <-- this is want you want}
  217.  
  218.         sectionEventMsgClass = 'sect';
  219.         sectionReadMsgID = 'read';
  220.         sectionWriteMsgID = 'writ';
  221.         sectionScrollMsgID = 'scrl';
  222.         sectionCancelMsgID = 'cncl';
  223.  
  224.     function InitEditionPack: OSErr;
  225.     inline
  226.         $3F3C, $0011, $303C, $0100, $A82D;
  227.     function NewSection (container: EditionContainerSpec; sectionDocument: FSSpecPtr; kind: SectionType; sectionID: LONGINT; initalMode: UpdateMode; var sectionH: SectionHandle): OSErr;
  228.     inline
  229.         $303C, $0A02, $A82D;
  230.     function RegisterSection (sectionDocument: FSSpec; sectionH: SectionHandle; var aliasWasUpdated: BOOLEAN): OSErr;
  231.     inline
  232.         $303C, $0604, $A82D;
  233.     function UnRegisterSection (sectionH: SectionHandle): OSErr;
  234.     inline
  235.         $303C, $0206, $A82D;
  236.     function IsRegisteredSection (sectionH: SectionHandle): OSErr;
  237.     inline
  238.         $303C, $0208, $A82D;
  239.     function AssociateSection (sectionH: SectionHandle; newSectionDocument: FSSpecPtr): OSErr;
  240.     inline
  241.         $303C, $040C, $A82D;
  242.     function CreateEditionContainerFile (editionFile: FSSpec; fdCreator: OSType; editionFileNameScript: ScriptCode): OSErr;
  243.     inline
  244.         $303C, $050E, $A82D;
  245.     function DeleteEditionContainerFile (editionFile: FSSpec): OSErr;
  246.     inline
  247.         $303C, $0210, $A82D;
  248.     function OpenEdition (subscriberSectionH: SectionHandle; var refNum: EditionRefNum): OSErr;
  249.     inline
  250.         $303C, $0412, $A82D;
  251.     function OpenNewEdition (publisherSectionH: SectionHandle; fdCreator: OSType; publisherSectionDocument: FSSpecPtr; var refNum: EditionRefNum): OSErr;
  252.     inline
  253.         $303C, $0814, $A82D;
  254.     function CloseEdition (whichEdition: EditionRefNum; successful: BOOLEAN): OSErr;
  255.     inline
  256.         $303C, $0316, $A82D;
  257.     function EditionHasFormat (whichEdition: EditionRefNum; whichFormat: FormatType; var formatSize: Size): OSErr;
  258.     inline
  259.         $303C, $0618, $A82D;
  260.     function ReadEdition (whichEdition: EditionRefNum; whichFormat: FormatType; buffPtr: univ Ptr; var buffLen: Size): OSErr;
  261.     inline
  262.         $303C, $081A, $A82D;
  263.     function WriteEdition (whichEdition: EditionRefNum; whichFormat: FormatType; buffPtr: univ Ptr; buffLen: Size): OSErr;
  264.     inline
  265.         $303C, $081C, $A82D;
  266.     function GetEditionFormatMark (whichEdition: EditionRefNum; whichFormat: FormatType; var currentMark: LONGINT): OSErr;
  267.     inline
  268.         $303C, $061E, $A82D;
  269.     function SetEditionFormatMark (whichEdition: EditionRefNum; whichFormat: FormatType; setMarkTo: LONGINT): OSErr;
  270.     inline
  271.         $303C, $0620, $A82D;
  272.     function GetEditionInfo (sectionH: SectionHandle; var editionInfo: EditionInfoRecord): OSErr;
  273.     inline
  274.         $303C, $0422, $A82D;
  275.     function GoToPublisherSection (container: EditionContainerSpec): OSErr;
  276.     inline
  277.         $303C, $0224, $A82D;
  278.     function GetLastEditionContainerUsed (var container: EditionContainerSpec): OSErr;
  279.     inline
  280.         $303C, $0226, $A82D;
  281.     function GetStandardFormats (container: EditionContainerSpec; var previewFormat: FormatType; preview: Handle; publisherAlias: Handle; formats: Handle): OSErr;
  282.     inline
  283.         $303C, $0A28, $A82D;
  284.     function GetEditionOpenerProc (var opener: EditionOpenerProcPtr): OSErr;
  285.     inline
  286.         $303C, $022A, $A82D;
  287.     function SetEditionOpenerProc (opener: EditionOpenerProcPtr): OSErr;
  288.     inline
  289.         $303C, $022C, $A82D;
  290.     function CallEditionOpenerProc (selector: EditionOpenerVerb; var PB: EditionOpenerParamBlock; routine: EditionOpenerProcPtr): OSErr;
  291.     inline
  292.         $303C, $052E, $A82D;
  293.     function CallFormatIOProc (selector: FormatIOVerb; var PB: FormatIOParamBlock; routine: FormatIOProcPtr): OSErr;
  294.     inline
  295.         $303C, $0530, $A82D;
  296.     function NewSubscriberDialog (var reply: NewSubscriberReply): OSErr;
  297.     inline
  298.         $303C, $0232, $A82D;
  299.     function NewSubscriberExpDialog (var reply: NewSubscriberReply; where: Point; expansionDITLresID: INTEGER; dlgHook: ExpDlgHookProcPtr; filterProc: ExpModalFilterProcPtr; yourDataPtr: univ Ptr): OSErr;
  300.     inline
  301.         $303C, $0B34, $A82D;
  302.     function NewPublisherDialog (var reply: NewPublisherReply): OSErr;
  303.     inline
  304.         $303C, $0236, $A82D;
  305.     function NewPublisherExpDialog (var reply: NewPublisherReply; where: Point; expansionDITLresID: INTEGER; dlgHook: ExpDlgHookProcPtr; filterProc: ExpModalFilterProcPtr; yourDataPtr: univ Ptr): OSErr;
  306.     inline
  307.         $303C, $0B38, $A82D;
  308.     function SectionOptionsDialog (var reply: SectionOptionsReply): OSErr;
  309.     inline
  310.         $303C, $023A, $A82D;
  311.     function SectionOptionsExpDialog (var reply: SectionOptionsReply; where: Point; expansionDITLresID: INTEGER; dlgHook: ExpDlgHookProcPtr; filterProc: ExpModalFilterProcPtr; yourDataPtr: univ Ptr): OSErr;
  312.     inline
  313.         $303C, $0B3C, $A82D;
  314.  
  315.  
  316.     { UsingEditions }
  317.  
  318.  
  319. implementation
  320. end.
  321.  
  322.